﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using log4net;
using log4net.Appender;

namespace LAVAA.UTILS
{
    public class SmtpAppenderWithHostInSubject : SmtpAppender
    {
        private string _subject;

        /// <summary>
        /// Send the email message
        /// </summary>
        /// <param name="messageBody">the body text to include in the mail</param>
        protected override void SendEmail(string messageBody)
        {
            _subject = (_subject ?? Subject);
            Subject = String.Format(_subject, Environment.MachineName);
            base.SendEmail(messageBody);
        }
    }

    public class Logger
    {
        private readonly ILog log;

        public Logger(Type type)
        {
            log = LogManager.GetLogger(type);
        }

        public void Info(string message)
        {
            log.Info(message);
        }

        public void Debug(string message)
        {
            log.Debug(message);
        }

        public void Error(string message)
        {
            log.Error(message);
        }

        public void Error(Exception ex)
        {
            log.Error(ex);
        }

        public void Fatal(string message)
        {
            log.Fatal(message);
        }

        public void Fatal(Exception ex)
        {
            log.Fatal(ex);
        }
    }
}
